"""
    Utility module with environment getters.
"""

import datetime

from mnemoply.model.environment import Environment


def getDefaultController(model_name):
    name = model_name.lower() +"_default_controller"
    controller = Environment.getValue(name)
    return controller or model_name

# When 2005-2006 returns 2005
def getAcademicYear():
    return int(Environment.getValue('academic_year'))

def getLessonStartDate():
    return datetime.date(day=1, month=9, year=getAcademicYear())

today = datetime.date.today()
now = datetime.datetime.now()

month_captions = (
    '-',
    _('January'),
    _('February'),
    _('March'),
    _('April'),
    _('May'),
    _('June'),
    _('July'),
    _('August'),
    _('September'),
    _('October'),
    _('November'),
    _('December'),
)

# Starting numeration from one!
day_captions = [
    '-',
    _('Monday'), _('Tuesday'),
    _('Wednesday'), _('Thursday'), _('Friday'),
    _('Saturday'), _('Sunday'),
]

actual_years = range(2008, today.year)

image_link = dict(
    delete = dict(img_src='/static/images/trash.png',
                  text = _("Delete"),
                  attrs = dict(onclick="return confirm('%s')"%
                               _("Are you sure you want to delete this?")),
                  link = 'delete',
                ),
    delete_yes =['show', 'edit'], # no: ['lookup', 'add'] 
    edit = dict(img_src='/static/images/edit.png',
                text= _("Edit"),
                link = 'edit_req',
                ),
    edit_yes =['show'], # no:  ['lookup','edit','add']
    lookup = dict(img_src='/static/images/table.gif',
                  text= _("List"),
                  link = '../list',
                ),
    lookup_yes = ['show','edit'],# no:  ['lookup'],
    lookup_add = dict(img_src='/static/images/table.gif',
                  text= _("List"),
                  link = 'list',
                ),
    lookup_add_yes = ['add'],# no:  ['lookup'],
    add = dict(img_src='/static/images/add.png',
               text = _("Add"),
               link = 'add_req',
              ),
    add_yes = ['lookup'], # no: ['add']

    show = dict(img_src='/static/images/icon_eye.gif',
                text = _("View"),
                link = 'show'
               ),
    show_yes = ['edit'], # no: ['lookup','edit','add']
    back = dict(img_src='/static/images/up.gif',
                text= _("Back"),
                link = 'javascript:history.back()'
               ),
    back_yes = []
    )
